import requests,time,random
# 设置请求超时时间
start=time.time()
timeout=random.randint(2,3)
response=requests.get(url='https://www.imooc.com',timeout=timeout)
end=time.time()
print(response.text)
delta=end-start
print(delta)
# 查看返回COOKIES
response=requests.get(url='https://www.baidu.com')
print(response.headers)
print(response.cookies)
print(response.cookies['BDORZ'])
# 设置请求头COOKIES
url='http://httpbin.org/cookies'
cookies=dict(cookies_are='hello imooc')
response=requests.get(url=url,cookies=cookies)
print(response.cookies)
print(response.headers)
print(response.text)
# 关闭默认开启的证书校验
url='https://www.baina.org'
try:
    response=requests.get(url=url)
except requests.exceptions.SSLError:
    print('Certificate does not exist.')
    response=requests.get(url=url,verify=False)
    print('Request succeed.')
except requests.exceptions.SSLError:
    print('Request failed.')
